﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ReflexTérkép.Tests.dto;

namespace ReflexTérkép.Tests
{
    [TestClass]
    public class ExceptionTests : TestBase
    {
        [TestMethod]
        [ExpectedException(typeof (ArgumentException))]
        public void Will_Throw_An_Exception_If_The_Type_Is_Not_Dynamic()
        {
            // Arrange
            var someObject = new object();
            var test = ReflexMapper.MapDynamic<Person>(someObject);
        }

        [TestMethod]
        public void Will_Not_Throw_An_Exception_If_The_List_Items_Are_Not_Dynamic()
        {
            // Arrange
            var someObjectList = new List<object> { null };

            // Act
            var test = ReflexMapper.MapDynamic<Person>(someObjectList);
            Assert.IsNotNull(test);
        }

        [TestMethod]
        public void Will_Return_An_Empty_List_Of_The_Requested_Type_When_Passed_An_Empty_List()
        {
            // Arrange
            var someObjectList = new List<object>();

            // Act
            var list = ReflexMapper.MapDynamic<Person>(someObjectList);

            // Assert
            Assert.IsNotNull(list);
            Assert.IsTrue(!list.Any()); 
        }
    }
}
